App({
    globalData: {
        hasLogin: !1,
        locateCityInfo: {
            id: 201,
            name: "北京",
            regionId: 110100,
            spell: "beijing"
        },
        selectCityParams: "",
        carcollect: [],
        isgetcarcollect: !1
    },
    onLaunch: function() {
        this.getLocateCity();
    },
    onShow: function() {
        wx.login({
            success: function(t) {
                t.code ? wx.request({
                    url: "https://wxs.app.yiche.com/login.ashx?op=getwechatid&js_code=" + t.code + "&label=" + Date.now(),
                    data: {},
                    success: function(t) {
                        wx.setStorageSync("opid", t.data.openid), wx.setStorageSync("session_key", t.data.session_key);
                    }
                }) : console.log("登录失败！" + t.errMsg);
            }
        });
    },
    onHide: function() {},
    getLocateCity: function() {
        var t = this;
        wx.getLocation({
            type: "wgs84",
            success: function(e) {
                var o = e.latitude + "," + e.longitude;
                wx.request({
                    url: "https://wxs.app.yiche.com/locationcity.ashx",
                    method: "GET",
                    header: {
                        "Content-Type": "application/json"
                    },
                    data: {
                        location: o
                    },
                    success: function(e) {
                        t.globalData.locateCityInfo = e.data;
                    },
                    fail: function() {
                        t.globalData.locateCityInfo = {
                            id: 201,
                            name: "北京",
                            regionId: 110100,
                            spell: "beijing"
                        };
                    }
                });
            },
            fail: function() {
                t.globalData.locateCityInfo = {
                    id: 201,
                    name: "北京",
                    regionId: 110100,
                    spell: "beijing"
                };
            }
        });
    },
    setSelectCityParam: function(t) {
        this.globalData.selectCityParams = t;
    },
    gotoIndex: function(t) {
        wx.openBluetoothAdapter ? wx.reLaunch({
            url: "../index/index"
        }) : wx.showModal({
            title: "提示",
            content: "当前微信版本过低，无法使用该功能，请升级到最新微信版本后重试。"
        });
    }
});